

using UnityEngine;
namespace JEngine.Framework
{
    public class MathfHelper 
    {
       
        #region 计算2D转向角度的Z

        /// <summary>
        /// 计算2D转向角度的Z
        /// </summary>
        /// <param name="dir">目标方向</param>
        /// <returns></returns>
        public  float AngleFromVector(Vector3 dir)
        {
            dir = dir.normalized;
            float n = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
            if (n < 0) n += 360;
            return n;
        }

        #endregion
        
        
        public static float RadToDeg(float radians)
        {
            return (float)(radians * 180 / System.Math.PI);
        }
        
        public static float DegToRad(float degrees)
        {
            return (float)(degrees * System.Math.PI / 180);
        }

      
    }
}
